package com.testmvc.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.testmvc.entity.User;
import com.testmvc.mapper.UserMapper;

@Controller
public class TestController {
	@Autowired
	UserMapper userMapper;
	
	@RequestMapping("/hi")
	String hi(Map<String, String> map) {
		User u=userMapper.testUser("am");
		map.put("username",u.getUsername());
		
		return "hi";
	}
	
	@RequestMapping("/add")
	String add(Map<String, String> map,String username,String password) {
		int i=userMapper.addUser(username, password);
		if(i>0) {
			User u=userMapper.testUser(username);
			map.put("username",u.getUsername());
		}
		return "hi";
	}
	
}
